package com.ftg.learn;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

/**
 * 抽人值日
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/3/2 下午4:21
 */
public class RandomHomeWork {

    public static void main(String[] args) {
        choose(2);
    }

    /**
     * 抽人
     *
     * @param num
     */
    public static void choose(int num) {
        assert num > 0;
        String[] str = new String[]{"董杨", "段凯", "房宁", "范忠芮", "李文博", "李文轩", "李祥", "吴宏博", "李岩松", "毛虹博",
                "石竺瑞", "苏晨",
                "苏荣婷",
                "陶冉", "王富", "王海林", "王鹤迪", "王磊"
                , "王新宇", "张宇", "朱天博"};
        Random random = new Random();
        Set<String> names = new HashSet<>();

        while (names.size() < num) {
            int a = random.nextInt(str.length);
            names.add(str[a]);
        }
        System.out.println(names);
    }

}
